msg="人生苦短，我爱Python"
# 字符串中的每个字符有自己对应的下标，通过下标进行取值即可，默认下标从0开始
print(msg[4])
# print(msg[22])    取值时，下标指定大于最大长度，会报下标越界异常
# 切片可以截取期中一段内容 [首坐标：尾坐标：步长]
# 切片取出的数据，不包含尾坐标
print(msg[0:4:2])
# 切片不会引起越界异常
print(msg[0:23])


ls=[1,"python",3.14]
for i in ls:
    print(i)
print(type(ls))
# 将列表进行反转操作
ls.reverse()
for i in ls:
    print(i)

list3=["python","java","mysql","springboot","mybatis"]
print(list3)
list3[4]="MybatisPlus"
print(list3)
list3.sort(reverse=False)
print(list3)
list3[4]="MybatisPlus"
print(list3)

# 元祖与列表类似，但是不允许修改元祖中的元素
tuple2=("java","python","mysql",8,["红桃A","黑桃K","梅花9"],"java")
print(type(tuple2))
# 元祖不允许修改
# tuple2[0]="javaEE"
print(tuple2[4])
tuple2[4][0]="黑桃A"
print(tuple2)
# 若元祖中只有一个元素，需要在元素末尾加上,
tuple3=("java",)
print(type(tuple3))

# 字典
dict1={"name":"zhangsan","age":25,"sex":True}
print(type(dict1))
print(dict1.get("name"))

print(dict1.items())
for key,value in dict1.items():
    print(key,value)
    pass